cmake_minimum_required(VERSION 3.5)
include(GNUInstallDirs)

project(dal_msg_test)

add_library(mj_interfaces__dalidl_typesupport_cpp SHARED
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_cpp/mj_interfaces/msg/mjtype__type_support.cpp
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_cpp/mj_interfaces/msg/mjtypeunder__type_support.cpp
)

target_include_directories(mj_interfaces__dalidl_typesupport_cpp PUBLIC
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_c
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_cpp
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_interface
    ${PROJECT_SOURCE_DIR}/depends/dalidl_generator_cpp
)

add_library(mj_interfaces__dalidl_typesupport_fastrtps_cpp SHARED
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_fastrtps_cpp/mj_interfaces/msg/detail/dds_fastrtps/mjtype__type_support.cpp
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_fastrtps_cpp/mj_interfaces/msg/detail/dds_fastrtps/mjtypeunder__type_support.cpp
)

target_include_directories(mj_interfaces__dalidl_typesupport_fastrtps_cpp PUBLIC
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_c
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_cpp
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_fastrtps
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_interface
    ${PROJECT_SOURCE_DIR}/depends/dalidl_generator_cpp
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_fastrtps_cpp
)

add_library(mj_interfaces__dalidl_typesupport_introspection_cpp SHARED
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_introspection_cpp/mj_interfaces/msg/detail/mjtype__type_support.cpp
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_introspection_cpp/mj_interfaces/msg/detail/mjtypeunder__type_support.cpp
)

target_include_directories(mj_interfaces__dalidl_typesupport_introspection_cpp PUBLIC
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_c
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_cpp
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_interface
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_introspection
    ${PROJECT_SOURCE_DIR}/depends/dalidl_generator_cpp
    ${PROJECT_SOURCE_DIR}/depends/dalidl_typesupport_introspection_cpp
)

add_executable(fastdds_pubsub
    fastdds_app/fastdds_pubsub.cpp
)

target_include_directories(fastdds_pubsub PUBLIC
    ${PROJECT_SOURCE_DIR}/depends/dalidl_generator_cpp)

target_link_libraries(fastdds_pubsub 
    dal_typesupport_fastdds_depends
    mj_interfaces__dalidl_typesupport_cpp
    fastrtps
    fastcdr)

# cyclonedds
add_executable(cyclonedds_pubsub
    ${PROJECT_SOURCE_DIR}/cyclonedds_app/cyclonedds_pubsub.cpp
)

target_link_libraries(cyclonedds_pubsub
    dal_typesupport_cyclonedds_depends
    mj_interfaces__dalidl_typesupport_cpp
    ddsc
    dl)

add_executable(cyclonedds_pub
    ${PROJECT_SOURCE_DIR}/cyclonedds_app/cyclonedds_pub.cpp
)

target_link_libraries(cyclonedds_pub
    dal_typesupport_cyclonedds_depends
    mj_interfaces__dalidl_typesupport_cpp
    ddsc
    dl)

add_executable(cyclonedds_sub
    ${PROJECT_SOURCE_DIR}/cyclonedds_app/cyclonedds_sub.cpp
)

target_link_libraries(cyclonedds_sub
    dal_typesupport_cyclonedds_depends
    mj_interfaces__dalidl_typesupport_cpp
    ddsc
    dl)

# rticonnextdds
if(${BUILD_RTIDDS})
if(CMAKE_EXTRA_SYSTEM MATCHES QNX)
    add_definitions(-DRTI_QNX)
else()
    add_definitions(-DRTI_UNIX)
endif()

add_executable(rticonnextdds_pubsub
    ${PROJECT_SOURCE_DIR}/rticonnextdds_app/rticonnextdds_pubsub.cpp
)

target_link_libraries(rticonnextdds_pubsub
    dal_typesupport_rticonnextdds_depends
    mj_interfaces__dalidl_typesupport_cpp
    fastcdr)
endif()

# dal_fastdds_msg_serdes_test
add_executable(dal_fastdds_msg_serdes_test
    dal_fastdds_msg_serdes_test/dal_fastdds_msg_serdes_test.cpp
    dal_fastdds_msg_serdes_test/my_package/dalidl_typesupport_cpp/my_package/msg/all_type__type_support.cpp
    dal_fastdds_msg_serdes_test/my_package/dalidl_typesupport_cpp/my_package/msg/all_type_under__type_support.cpp
    dal_fastdds_msg_serdes_test/my_package/dalidl_typesupport_fastrtps_cpp/my_package/msg/detail/dds_fastrtps/all_type__type_support.cpp
    dal_fastdds_msg_serdes_test/my_package/dalidl_typesupport_fastrtps_cpp/my_package/msg/detail/dds_fastrtps/all_type_under__type_support.cpp
)

target_include_directories(dal_fastdds_msg_serdes_test PUBLIC
    dal_fastdds_msg_serdes_test/my_package/dalidl_generator_cpp
    dal_fastdds_msg_serdes_test/my_package/dalidl_typesupport_fastrtps_cpp
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_c
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl/dalidl_runtime_cpp
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_fastrtps
    ${PROJECT_SOURCE_DIR}/../../dal_msg/include/dalidl_typesupport_interface
)

target_link_libraries(dal_fastdds_msg_serdes_test
    dal_typesupport_fastdds_depends fastrtps fastcdr)
